﻿<Window x:Class="Sentinel.Images.Controls.AddImageWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:conv="clr-namespace:WpfExtras.Converters;assembly=WpfExtras"
        Title="Add Image"
        WindowStartupLocation="CenterOwner"
        ShowInTaskbar="False"
        WindowStyle="SingleBorderWindow"
        MinHeight="400"
        MinWidth="470"
        SizeToContent="WidthAndHeight">

    <Window.Resources>
        <conv:VisibilityToHiddenConverter x:Key="visConverter" />
    </Window.Resources>
    
    <DockPanel Height="Auto"
                   Margin="6">
            <StackPanel Orientation="Horizontal"
                        Height="36"
                        HorizontalAlignment="Right"
                        DockPanel.Dock="Bottom"
                        Margin="0,10,0,0">
                <Button Content="_OK"
                        Command="{Binding Accept}"
                        Width="80"
                        Margin="0,5"
                        IsDefault="True" />
                <Button Content="_Cancel"
                        Command="{Binding Reject}"
                        Width="80"
                        Margin="5,5,0,5"
                        IsCancel="True" />
            </StackPanel>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Row="0"
                       Text="Type name : "
                       Margin="5"
                       VerticalAlignment="Center" />
            <TextBox Grid.Row="0"
                     Grid.Column="1" 
                     Grid.ColumnSpan="2"
                     Margin="5"
                     VerticalAlignment="Center"
                     IsEnabled="{Binding IsAddMode}"
                     Text="{Binding Type, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/>
            
            <TextBlock Grid.Row="1"
                       Text="Size : "
                       Margin="5"
                       VerticalAlignment="Center" />
            <ComboBox Grid.Row="1"
                      Grid.Column="1"
                      Grid.ColumnSpan="2"
                      Margin="5"
                      SelectedIndex="0"
                      SelectedValuePath="Content"
                      IsEnabled="{Binding IsAddMode}"
                      SelectedValue="{Binding Size, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}">
                <ComboBoxItem Content="Small" />
                <ComboBoxItem Content="Medium" />
                <ComboBoxItem Content="Large" />
            </ComboBox>
            
            <Border Grid.Row="2"
                    Grid.Column="0"
                    Grid.RowSpan="1"
                    Grid.ColumnSpan="3"
                    Margin="5"
                    Padding="5"
                    CornerRadius="3"
                    BorderThickness="1"
                    BorderBrush="Black">
                <Image x:Name="imagePreview"
                       Source="{Binding Image}"
                       MaxWidth="128"
                       Width="Auto"
                       MaxHeight="128"
                       Height="Auto"
                       Margin="15"
                       Stretch="None" />
            </Border>
            <TextBlock Grid.Row="3"
                       Text="Image file : "
                       Margin="5"
                       VerticalAlignment="Center" />
            <TextBox Grid.Row="3"
                     Grid.Column="1"
                     Text="{Binding FileName, UpdateSourceTrigger=PropertyChanged}"
                     Margin="5"
                     VerticalAlignment="Center"
                     IsReadOnly="True" />
            <Button Content="_..."
                    Command="{Binding Browse}"
                    Grid.Row="3"
                    Grid.Column="2"
                    VerticalAlignment="Top"
                    HorizontalAlignment="Center"
                    Width="22"
                    Height="22"
                    Margin="2,5,0,5"/>
            <TextBlock Grid.Row="5"
                       Grid.ColumnSpan="3"
                       Foreground="Red"
                       Margin="5"
                       TextWrapping="WrapWithOverflow"
                       Visibility="{Binding IsValid, Converter={StaticResource visConverter}, ConverterParameter=true}"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Center"
                       Text="{Binding Error}" />
        </Grid>
    </DockPanel>
</Window>